import React, { Component } from "react";
import { createPortal } from "react-dom";

// 高阶组件的取名约定用with开头
const withPortal = (Comp) => {
  return class extends Component {
    render() {
      return createPortal(
        <Comp {...this.props} />,
        document.querySelector("body")
      );
    }
  };
};

export default withPortal;
